package get.data;

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.provider.OpenableColumns;

public class DatabaseHandler extends Activity{
	
    public static final String DB_NAME = "MyDatabase";
    public static final String DB_PATH = "/data/data/get.data/databases/";
    public static final String NODES = "Nodes";
	
    public static boolean checkDataBase(SQLiteDatabase db){
    	  
    	boolean created = false;
    	
    	try{
			String sql = "SELECT * FROM "+ DatabaseHandler.NODES;
			Cursor c = Main.db.rawQuery(sql, null);
			System.out.println("Cursor "+c.getCount()+"");
    		created = true;
    		if(c.getCount() == 0)
    			created = false;
    		c.close();
    	}catch(SQLiteException e){ 
    		
    	}
 
    	return created;
    }
    
    public static void createNodesTable(SQLiteDatabase db){
    	
        String CREATE_TABLE=
            "CREATE TABLE " + NODES + "("
            + "cnt INTEGER PRIMARY KEY AUTOINCREMENT,"
            + "id STRING, ip STRING, coordx INEGER, coordy INEGER);";
        db.execSQL(CREATE_TABLE);
    	
    }
	


}
